package com.rajeshDyadav.datetime;

import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Example03 {
    public static void main(String[] args) throws ParseException {
	String appDateFormat = "dd/MM/yy";
	SimpleDateFormat sdf = new SimpleDateFormat(appDateFormat);
	
	String strTranDate = "11/03/13";
	Date tranDate =  sdf.parse(strTranDate);
	System.out.println("tranDate ..> " + tranDate);

	Calendar calendar = Calendar.getInstance();;
	calendar.setTime(tranDate);
	
	int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
	
	if (dayOfMonth <= 7) {
	    calendar.set(Calendar.DAY_OF_MONTH, 5);
	}
	else if (dayOfMonth <= 21) {
	    calendar.set(Calendar.DAY_OF_MONTH, 14);
	}
	else {
	    calendar.set(Calendar.DAY_OF_MONTH, 23);
	}
	
	System.out.println(calendar.getTime());
	
	/*
	calendar.set(Calendar.DAY_OF_MONTH, 1);
	calendar.set(Calendar.HOUR_OF_DAY,0);
	calendar.set(Calendar.MINUTE, 0);
	calendar.set(Calendar.SECOND, 0);
	*/
	
	Timestamp timestamp = new Timestamp(calendar.getTimeInMillis());
	System.out.println(sdf.format(timestamp));
    }
}
